// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2024-11-01',
  devtools: { enabled: true },
  modules: ['@pinia/nuxt', '@element-plus/nuxt'],
  // 引入全局样式
  css: ['~/styles/global.scss', 'vant/lib/index.css'],
  devServer: {
    port: 5173,
    host: '0.0.0.0'
  },
  $production: {

  },
  $development: {

  },
  vite: {
    // 配置代理
    server: {
      proxy: {
        "^/express": {
          target:  process.env.BASEURL, // import.meta.env.BASEURL,
          changeOrigin: true,
          rewrite: path => path.replace(/\/express/, '')
        }
      }
    },
    css: {
      postcss: {
        plugins: [require('postcss-pxtorem')({ rootValue: 10, propList: ['*'] })]
      },
      preprocessorOptions: {
        scss: {
          // additionalData: '@use ~/styles/global.scss as *'
          silenceDeprecations: ['legacy-js-api']  // 解除sass警告
        }
      }
    }
  },
  // 运行时全局变量
  runtimeConfig: {
    // 只能在服务端获取
    count: 1,
    public: {
      BASEURL: process.env.BASEURL || '',
      NUXT_WEB_LOCAL: process.env.NUXT_WEB_LOCAL || ''
    }
  }
})